home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / inventor / noodle / LineManip.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  3.8 KB  |  143 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. //
  18. // A very specialized node; this manipulator completely takes care of
  19. // editing a set of line segments.
  20. //
  21.  
  22. #include <Inventor/SbLinear.h>
  23. #include <Inventor/SbViewportRegion.h>
  24. #include <Inventor/nodes/SoSeparator.h>
  25.  
  26. extern class SbColor;
  27. extern class SbPlaneProjector;
  28. extern class SbLineProjector;
  29. extern class SbVec3f;
  30. extern class SoCoordinate3;
  31. extern class SoDrawStyle;
  32. extern class SoHandleEventAction;
  33. extern class SoLineSet;
  34. extern class SoLocation2Event;
  35. extern class SoMaterial;
  36. extern class SoPath;
  37. extern class SoPointSet;
  38. extern class SoSwitch;
  39. extern class SoTransform;
  40.  
  41. class LineManip2 : public SoSeparator
  42. {
  43.     SO_NODE_HEADER(LineManip2);
  44.  
  45.   public:
  46.     LineManip2();
  47.     virtual ~LineManip2();
  48.  
  49.     //
  50.     // Return the coordinates being edited.  Put a data sensor on
  51.     // these to get notified whenever they are changed.
  52.     //
  53.     SoCoordinate3 *getCoordinate3();
  54.     void setCoordinate3( SoCoordinate3 *newNode );
  55.  
  56.   //
  57.   // THIS MUST BE CALLED BEFORE THE CLASS IS USED!
  58.   // (SoInteraction::init() calls this for all of the built-in
  59.   // manipulator)
  60.   //
  61.     static void initClass();
  62.  
  63.     //
  64.     // Get rid of any hilights.  This can be called when the mouse
  65.     // leaves the window, for example.
  66.     //
  67.     virtual void removeHilights();
  68.  
  69.     //
  70.     // Handle an event.  This is meant to be internal only.
  71.     //
  72.     virtual void handleEvent(SoHandleEventAction *);
  73.  
  74.     //
  75.     // Controls how big the feedback is.  Default is
  76.     // 0.05.
  77.     //
  78.     virtual void setHilightSize(float);
  79.  
  80.     // Sets the normal to the projection plane.
  81.     void setPlaneNormal( const SbVec3f &newNormal );
  82.  
  83.   SoEXTENDER public:
  84.  
  85.     // Records the viewport size and viewVolume at the time when the
  86.     // manipulator grabs the events.
  87.     // Automatically called by the handleEventAction when this manip 
  88.     // grabs events with ha->setGrabber(this)
  89.     // Also turns renderCaching off during the time we are the grabber.
  90.     virtual void grabEventsSetup();
  91.     virtual void grabEventsCleanup();
  92.  
  93.   private:
  94.     SoCoordinate3 *coord, *hilightCoord;
  95.     int current_coord;
  96.     float hilightSize;
  97.     SbVec3f current_position;
  98.     SoPointSet *pset;
  99.     SoDrawStyle *drawStyle;
  100.     SoLineSet *lset;
  101.     SbPlaneProjector *planeProj;
  102.     SbLineProjector  *lineProj;
  103.  
  104.     SoTransform *hilightTransform;
  105.     SoMaterial *hilightMaterial;
  106.     SoSwitch *hilightSwitch;
  107.  
  108. #ifdef __C_PLUS_PLUS_2
  109.     enum LineManipPart {
  110. #else
  111.     enum Part {
  112. #endif
  113.     POINTS,
  114.     LINES,
  115.     ENDPOINTS,
  116.     NOTHING,
  117.     };
  118.  
  119. #ifdef __C_PLUS_PLUS_2
  120.     LineManipPart whichPart();
  121. #else
  122.     Part whichPart();
  123. #endif
  124.     SbBool dragStart();
  125.     SbBool remove();
  126.     void updateProjectors( const SbVec3f &curPt );
  127.     void projectMouse(SbVec3f &);
  128.     
  129.     SbBool locateHilight();
  130.     void moveCoord();
  131.     void initHilightStuff();
  132.     void hilightVertex(const SbVec3f &, const SbColor &);
  133.     void hilightLine(int, const SbVec3f &, const SbColor &);
  134.  
  135.     SbVec3f planeNormal;
  136.  
  137.     CacheEnabled savedRenderCachingVal;
  138.     SbViewVolume        myViewVolume;
  139.     SbViewportRegion    myVpRegion;
  140.     SoHandleEventAction *myHandleEventAction;
  141.     void extractViewingParams( SoHandleEventAction *);
  142. };
  143.